#!/usr/bin/env bash

# Copyright 2016 The Fuchsia Authors
#
# Use of this source code is governed by a MIT-style
# license that can be found in the LICENSE file or at
# https://opensource.org/licenses/MIT

SCRIPTSDIR=`dirname $0`
CLANGFMT=$SCRIPTSDIR/clang-format

if [ ! -f "$CLANGFMT" ]; then
  echo "local clang-format not found. Running scripts/fetch-clang-fmt to get it."
  ( cd $SCRIPTSDIR && ./fetch-clang-fmt )
fi

if [ ! -f $CLANGFMT ]; then
  echo "$CLANGFMT still not found. Exiting."
  exit 0
fi

$CLANGFMT -i -style=file $@
